package com.xbs.controller.enterprise;

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.sql.Date;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.xbs.controller.base.BaseServlet;
import com.xbs.service.enterprise.EpOrderAdminService;
@WebServlet("*.ou")
public class EpOrderUpdateAdminController extends BaseServlet{
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// 获取servlterd的路径
		String servletPath = req.getServletPath();
		// 获取方法名称
		System.out.println(servletPath);
		String methodName = servletPath.substring(27, servletPath.length() - 3);
		System.out.println(methodName);
		try {
			// 获取方法
			Method method = getClass().getDeclaredMethod(methodName, HttpServletRequest.class,
					HttpServletResponse.class);
			method.invoke(this, req, resp);
		} catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException
				| InvocationTargetException e) {
			e.printStackTrace();

		}

		
	}
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req, resp);
	}
	private void upzt(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		EpOrderAdminService service=new EpOrderAdminService();
		String id=req.getParameter("id");
		String status=req.getParameter("status");
		service.updateZt(id, status);
		
	}
	private void upje(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		EpOrderAdminService service=new EpOrderAdminService();
		String id=req.getParameter("id");
		Double cash=Double.parseDouble(req.getParameter("cash"));
		service.updateJe(id, cash);
		
	}
	private void upmark(HttpServletRequest req,HttpServletResponse resp) throws ServletException,IOException{
		EpOrderAdminService service=new EpOrderAdminService();
		String id=req.getParameter("id");
		String mark=req.getParameter("mark");
		service.updateMark(id, mark);
	}
	
	private void seedetail(HttpServletRequest req,HttpServletResponse resp) throws ServletException,IOException{
		EpOrderAdminService service=new EpOrderAdminService();
		String id=req.getParameter("id");
		String mark=req.getParameter("mark");
		service.updateMark(id, mark);
	}
	
	
	private void setreturntime(HttpServletRequest req,HttpServletResponse resp) throws ServletException,IOException{
		EpOrderAdminService service=new EpOrderAdminService();
		String id=req.getParameter("id");
		String returnTime=req.getParameter("returnTime");
		service.updateReturntime(id, Date.valueOf(returnTime));
	}
}
